package com.fdb.efp.nls.service.impl;

import com.fdb.efp.nls.service.domain.WsApproveackConfirm;
import com.fdb.efp.nls.service.facade.WsApproveackConfirmService;
import com.fdb.efp.nls.service.vo.WsApproveackConfirmVO;
import com.fdb.basic.framework.core.base.FrameworkService;
import com.fdb.efp.nls.service.dao.WsApproveackConfirmDao;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Objects;


/**
 * Service Impl: 网商授信终审应答信息表服务实现
 * @author ligm
 * @date 2019-08-08 
 */
@Service("wsApproveackConfirmService")
public class WsApproveackConfirmServiceImpl implements WsApproveackConfirmService, FrameworkService {
	
	private static Logger logger = LoggerFactory.getLogger(WsApproveackConfirmServiceImpl.class);

	@Autowired
	private WsApproveackConfirmDao wsApproveackConfirmDao;

   	/**
	 * 新增数据 
     * @param inWsApproveackConfirmVo
     * @return 
	 */
	public int insertWsApproveackConfirm(WsApproveackConfirmVO inWsApproveackConfirmVo) {
		logger.debug("当前新增数据为:"+ inWsApproveackConfirmVo.toString());
		int num = 0;
		try {
			WsApproveackConfirm wsApproveackConfirm = new WsApproveackConfirm();
			beanCopy(inWsApproveackConfirmVo, wsApproveackConfirm);
			num = wsApproveackConfirmDao.insertWsApproveackConfirm(wsApproveackConfirm);
		} catch (Exception e) {
			logger.error("新增数据发生异常!", e);
			num = -1;
		}
		logger.debug("当前新增数据条数为:"+ num);
		return num;
	}

    /**
	 * 根据主键删除信息 
	 * @param inWsApproveackConfirmVo
 	 * @return
	 */
	public int deleteByPk(WsApproveackConfirmVO inWsApproveackConfirmVo) {
		logger.debug("当前删除数据条件为:"+ inWsApproveackConfirmVo);
		int num = 0;
		try {
			WsApproveackConfirm wsApproveackConfirm = new WsApproveackConfirm();
			beanCopy(inWsApproveackConfirmVo, wsApproveackConfirm);
			num = wsApproveackConfirmDao.deleteByPk(wsApproveackConfirm);
		} catch (Exception e) {
			logger.error("删除数据发生异常!", e);
			num = -1;
		}
		logger.debug("根据条件:"+ inWsApproveackConfirmVo +"删除的数据条数为"+ num);
		return num;
	}


    /**
	 * 根据主键更新信息 
	 * @param inWsApproveackConfirmVo
	 * @return 
	 */  
	public int updateByPk(WsApproveackConfirmVO inWsApproveackConfirmVo) {
		logger.debug("当前修改数据为:"+ inWsApproveackConfirmVo.toString());
		int num = 0;
		try {
			WsApproveackConfirm wsApproveackConfirm = new WsApproveackConfirm();
			beanCopy(inWsApproveackConfirmVo, wsApproveackConfirm);
			num = wsApproveackConfirmDao.updateByPk(wsApproveackConfirm);
		} catch (Exception e) {
			logger.error("修改数据发生异常!", e);
			num = -1;
		}
		logger.debug("根据条件:"+ inWsApproveackConfirmVo +"修改的数据条数为"+ num);
		return num;
	}
	
    /**
	 * 根据主键查询详情 
	 * @param wsApproveackConfirm
	 * @return 
	 */
	public WsApproveackConfirmVO queryByPk(WsApproveackConfirmVO inWsApproveackConfirmVo) {
		
		logger.debug("当前查询参数信息为:"+ inWsApproveackConfirmVo);
		try {
			WsApproveackConfirm queryWsApproveackConfirm = new WsApproveackConfirm();
			beanCopy(inWsApproveackConfirmVo, queryWsApproveackConfirm);
			WsApproveackConfirm queryRslWsApproveackConfirm = wsApproveackConfirmDao.queryByPk(queryWsApproveackConfirm);
			if (Objects.nonNull(queryRslWsApproveackConfirm)) {
				WsApproveackConfirmVO outWsApproveackConfirmVo = beanCopy(queryRslWsApproveackConfirm, new WsApproveackConfirmVO());
				logger.debug("当前查询结果为:"+ outWsApproveackConfirmVo.toString());
				return outWsApproveackConfirmVo;
			} else {
				logger.debug("当前查询结果为空!");
			}
		} catch (Exception e) {
			logger.error("查询数据发生异常!", e);
		}
		return null;
	}


    /**
	 * 一级数据权限 
	 * @param wsApproveackConfirm
	 * @return 
	 */	
	@SuppressWarnings("unchecked")
	public List<WsApproveackConfirmVO> queryAllByLevelOne(WsApproveackConfirmVO wsApproveackConfirmVo) {
		logger.debug("查看当前用户对应的数据信息的参数信息为:");
		List<WsApproveackConfirmVO> list = null;
		try {
			List<WsApproveackConfirm> wsApproveackConfirms = wsApproveackConfirmDao.queryAllByLevelOneByPage(wsApproveackConfirmVo);
			logger.debug("查看当前用户对应的数据信息的结果集数量为:"+ wsApproveackConfirms.size());
			pageSet(wsApproveackConfirms, wsApproveackConfirmVo);
			list = (List<WsApproveackConfirmVO>) beansCopy(wsApproveackConfirms, WsApproveackConfirmVO.class);
		} catch (Exception e) {
			logger.error("数据转换出现异常!", e);
		}
		
		return list;
	
	}


    /**
	 * 二级数据权限 
	 * @param wsApproveackConfirm
	 * @return 
	 */
	@SuppressWarnings("unchecked")
	public List<WsApproveackConfirmVO> queryAllByLevelTwo(WsApproveackConfirmVO wsApproveackConfirmVo) {
		logger.debug("查看当前用户及所属机构对应的数据信息的参数信息为:");
		List<WsApproveackConfirm> wsApproveackConfirms = wsApproveackConfirmDao.queryAllByLevelTwoByPage(wsApproveackConfirmVo);
		logger.debug("查看当前用户及所属机构对应的数据信息的结果集数量为:"+wsApproveackConfirms.size());
		List<WsApproveackConfirmVO> list = null;
		try {
			pageSet(wsApproveackConfirms, wsApproveackConfirmVo);
			list = (List<WsApproveackConfirmVO>) beansCopy(wsApproveackConfirms, WsApproveackConfirmVO.class);
		} catch (Exception e) {
			logger.error("数据转换出现异常!", e);
		}
		
		return list;
	
	}


    /**
	 * 三级数据权限 
	 * @param wsApproveackConfirm
	 * @return 
	 */
	@SuppressWarnings("unchecked")
	public List<WsApproveackConfirmVO> queryAllByLevelThree(WsApproveackConfirmVO wsApproveackConfirmVo) {
		logger.debug("查看当前用户所在机构及下属机构对应的数据信息的参数信息为:");
		List<WsApproveackConfirm> wsApproveackConfirms = wsApproveackConfirmDao.queryAllByLevelThreeByPage(wsApproveackConfirmVo);
		logger.debug("查看当前用户所在机构及下属机构对应的数据信息的结果集数量为:"+ wsApproveackConfirms.size());
		List<WsApproveackConfirmVO> list = null;
		try {
			pageSet(wsApproveackConfirms, wsApproveackConfirmVo);
			list = (List<WsApproveackConfirmVO>) beansCopy(wsApproveackConfirms, WsApproveackConfirmVO.class);
		} catch (Exception e) {
			logger.error("数据转换出现异常!", e);
		}
		
		return list;
	}

    /**
	 * 四级数据权限  
	 * @param wsApproveackConfirm
	 * @return 
	 */
	@SuppressWarnings("unchecked")
	public List<WsApproveackConfirmVO> queryAllByLevelFour(WsApproveackConfirmVO wsApproveackConfirmVo) {
		logger.debug("【预留，便于后续自定义 】信息的参数信息为:");
		List<WsApproveackConfirm> wsApproveackConfirms = wsApproveackConfirmDao.queryAllByLevelFourByPage(wsApproveackConfirmVo);
		logger.debug("【预留，便于后续自定义 】信息的结果集数量为:"+ wsApproveackConfirms.size());
		List<WsApproveackConfirmVO> list = null;
		try {
			pageSet(wsApproveackConfirms, wsApproveackConfirmVo);
			list = (List<WsApproveackConfirmVO>) beansCopy(wsApproveackConfirms, WsApproveackConfirmVO.class);
		} catch (Exception e) {
			logger.error("数据转换出现异常!", e);
		}
		
		return list;
	}

    /**
	 * 五级数据权限  
	 * @param wsApproveackConfirm
	 * @return 
	 */
	@SuppressWarnings("unchecked")
	public List<WsApproveackConfirmVO> queryAllByLevelFive(WsApproveackConfirmVO wsApproveackConfirmVo) {
		logger.debug("【预留，便于后续自定义 】信息的参数信息为:");
		List<WsApproveackConfirm> wsApproveackConfirms = wsApproveackConfirmDao.queryAllByLevelFiveByPage(wsApproveackConfirmVo);
		logger.debug("【预留，便于后续自定义 】信息的结果集数量为:"+ wsApproveackConfirms.size());
		List<WsApproveackConfirmVO> list = null;
		try {
			pageSet(wsApproveackConfirms, wsApproveackConfirmVo);
			list = (List<WsApproveackConfirmVO>) beansCopy(wsApproveackConfirms, WsApproveackConfirmVO.class);
		} catch (Exception e) {
			logger.error("数据转换出现异常!", e);
		}
		
		return list;
	}

	@Override
	public WsApproveackConfirmVO queryByApplyNo(String applyNo) {
		logger.debug("当前查询参数信息为:"+ applyNo);
		try {
			WsApproveackConfirm queryRslWsApproveackConfirm = wsApproveackConfirmDao.queryByApplyNo(applyNo);
			if (Objects.nonNull(queryRslWsApproveackConfirm)) {
				WsApproveackConfirmVO outWsApproveackConfirmVo = beanCopy(queryRslWsApproveackConfirm, new WsApproveackConfirmVO());
				logger.debug("当前查询结果为:"+ outWsApproveackConfirmVo.toString());
				return outWsApproveackConfirmVo;
			} else {
				logger.debug("当前查询结果为空!");
			}
		} catch (Exception e) {
			logger.error("查询数据发生异常!", e);
		}
		return null;
	}
}
